package com.open.capacity.user.controller;

import com.open.capacity.common.model.Title;
import com.open.capacity.common.web.PageResult;
import com.open.capacity.common.web.Result;
import com.open.capacity.user.service.TitleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 称号控制层
 * @author liutao
 * @date 2021-02-01 16:32
 */

@RestController
@RequestMapping("/title")
@Api(tags = "称号管理")
public class TiltleController {

    @Autowired
    private TitleService titleService;

    // 模糊查询称号
    @PostMapping("/getSelectTitles")
    @ApiOperation(value = "模糊查询称号")
    public PageResult<Title> getSelectTitles(@RequestParam Map<String, Object> params){
        return titleService.getSelectTitles(params);
    }

    // 添加称号
    @PostMapping("/addTitle")
    @ApiOperation(value = "添加称号")
    public Result addTitle(@RequestBody Title title){
        return titleService.addTitle(title);
    }

    // 修改称号
    @PostMapping("/updateTitle")
    @ApiOperation(value = "修改称号")
    public Result updateTitle(@RequestBody Title title){
        return titleService.updateTitle(title);
    }

    // 删除称号
    @DeleteMapping("/delTitle/{titlid}")
    @ApiOperation(value = "删除称号")
    public Result delTitle(@PathVariable("titlid") int titlid){
        return titleService.delTitle(titlid);
    }

    // 查询自己获得的称号
    @PostMapping("/getTitleByUserId")
    @ApiOperation(value = "查询自己获得的称号")
    public PageResult getTitleByUserId(@RequestParam Map<String, Object> params){
        return titleService.getTitleByUserId(params);
    }

    //

}
